\documentclass[]{article}
\usepackage{amsmath}
\usepackage{amssymb}
%opening
\title{Optimal Control - Homework Excerise 1}
\author{  Henrik Edlund, 900202-4736, hened061\\ 
Johan Andersson 900612-0332, johan474}

\begin{document}

\maketitle
\subsection*{a)} 
To formulate the problem as a discrete-time optimal programming problem, the following form is used,
\begin{align*}
\max \: \phi(x_N)+\sum_{k=0}^{N-1}f_0(k,x_k,u_k) \\
sbj. to \quad x_{k+1}=f(k,x_k,u_k) 
\end{align*}
From the problem formulation the following is obtained,
\begin{align*}
\phi(x_N)&=0 \quad \mbox{(Not interested in maximizing profit)}\\
f_0(k,x_k,u_k)&=u_k \\
f(k,x_k,u_k) &= x_k+\theta(x_k - u_k)
\end{align*}
with the constraint,
\begin{equation*}
0 \leq u_k \leq x_k
\end{equation*}


\subsection*{b)}
The DP-algorithm is used and results in the following recursion,
\begin{align*}
&J(N,x)=\phi(x_N) \\
&J(n,x)=\max \: \{f_0(n,x,u)+J(n+1,x,u)   \}
\end{align*}
Since the problem is linear the optimal values will be found at the constraints. If the term in front of u is negative the optimum will be found at u=0. If the term is positive the optimum is found at u=x.

To show that $J(k,x)=\alpha_kx$ with $\alpha_{k-1} = \alpha_k+max\{\theta\alpha_k,1\}$ holds, the algorithm is applied for an arbitrary k.

\begin{align*}
J(k-1,x)&=\max\{u+\alpha_k(x+\theta(x - u))\}=\max\{u(1-\alpha_k\theta)+\alpha_kx(1+\theta) \}=\\&=
\Bigg/u_k=\begin{cases}
x &\alpha_k\theta < 1
\\
0 &\alpha_k\theta \geq 1
\end{cases}\Bigg/=
\begin{cases}
(1+\alpha_k)x &\alpha_N\theta < 1
\\
\alpha_k(1+\theta)x &\alpha_N\theta \geq 1
\end{cases}
\end{align*}
Thus, 
\begin{align*}
\alpha_{k-1}=
\begin{cases}
(1+\alpha_k) &\alpha_k\theta < 1
\\
\alpha_k(1+\theta) &\alpha_k\theta \geq 1
\end{cases}
\end{align*}
which is easily seen to be equivalent to,
\begin{align*}
\alpha_{k-1} = \alpha_k+\max\{\theta\alpha_k,1\}
\end{align*}
It can also be seen that,
\begin{align*}
J(k,x)=\alpha_kx
\end{align*}

\subsection*{c)}
The starting value for the backward recursion is obtained from,
\begin{align*}
J(N,x)&=\phi(x)=0=\alpha_Nx,\:\Leftrightarrow \alpha_N = 0
\end{align*}

The solution to this problem can be divided into two phases, one investment phase and one distribution phase. In the investment phase all the profit is invested and in the distribution phase all profit is distributed. The length of these phases determines the optimal solution. 

The optimal control signal has the following form,

\begin{align*}
u^*_k= 
\begin{cases}
x_k \quad &\alpha_k \theta < 1
\\
0 \quad &\alpha_k \theta \geq 1
\end{cases}
\end{align*}
Since $\alpha_k$ is increasing for lower values of k there will be a switch-point in the control signal when $\alpha_k \theta<1$, where u goes from x to 0. Before the switch point, $\alpha_{k-1}=1+\alpha_k$.
Starting from $\alpha_N=0$ and going to $\alpha_{N-n}$ which is last $\alpha_k$ which satisfies $\alpha_k \theta < 1$. Then, 
\begin{align*}
\alpha_{N-n}=n=\Big \lfloor \frac{1}{\theta}\Big\rfloor
\end{align*}
which is the amount of times the profit is distributed at the distribution phase at the end.

The following optimal control is obtained,
\begin{align*}
u^*_k= 
\begin{cases}
x_k \quad k \geq N-n
\\
0 \quad k< N-n
\end{cases}
\end{align*}


\end{document}
